package com.yc.blog.springmvc.jsp.ctr;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.yc.blog.springmvc.jsp.pojo.DemoResult1;

/**
 * 直接返回数据
 */
@Controller
public class DemoController2 {
	
	/**
	 * 增加@ResponseBody
	 * 直接返回字符串
	 * @return
	 */
	@RequestMapping("/c2-1")
	@ResponseBody
	public String c1() {
		System.out.println("--------c1-1---------");
		
		return "success";
	}

	/**
	 * 增加@ResponseBody
	 * 直接返回对象，被自动转为json
	 * @param modelAndView
	 * @return
	 */
	@RequestMapping("/c2-2")
	@ResponseBody
	public DemoResult1 c1(ModelAndView modelAndView) {
		System.out.println("--------c2-1---------");
		
		DemoResult1 dr = new DemoResult1("2aaaa1", "2bbbb1");
		
		return dr;
	}
}
